import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

Vue.use(Router)

export default new Router({
  // mode: 'history',
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      meta: { // 表示需要登录
        requireAuth: 'true'
      }
    },
    { // 登陆
      path: '/login',
      name: 'login',
      component: () => import('./views/Login/Index.vue')
    },
    { // 个人中心
      path: '/personalCenter',
      name: 'personalCenter',
      component: () => import('./views/PersonalCenter/PersonalCenter.vue'),
      children: [
        { // 为空时
          path: '',
          component: () => import('./views/PersonalCenter/components/Lately.vue'),
          meta: { // 表示需要登录
            requireAuth: 'true'
          }
        },
        { // 个人中心
          path: 'lately',
          name: 'lately',
          meta: { // 表示需要登录
            requireAuth: 'true'
          },
          component: () => import('./views/PersonalCenter/components/Lately.vue')
        },
        { // 激活的题目
          path: 'active',
          name: 'active',
          meta: { // 表示需要登录
            requireAuth: 'true'
          },
          component: () => import('./views/PersonalCenter/components/Active.vue')
        },
        { // 资讯收藏
          path: 'info',
          name: 'info',
          meta: { // 表示需要登录
            requireAuth: 'true'
          },
          component: () => import('./views/PersonalCenter/components/Info.vue')
        }
      ]
    },
    { // 题库练习
      path: '/practise',
      name: 'practise',
      meta: { // 表示需要登录
        requireAuth: 'true'
      },
      component: () => import('./views/Practise.vue')
    },
    { // 历年真题
      path: '/calendar',
      name: 'calendar',
      meta: { // 表示需要登录
        requireAuth: 'true'
      },
      component: () => import('./views/Calendar.vue')
    },
    { // 模拟考试
      path: '/simulation',
      name: 'simulation',
      meta: { // 表示需要登录
        requireAuth: 'true'
      },
      component: () => import('./views/Simulation.vue')
    },
    { // 解析页面
      path: '/analysis',
      name: 'analysis',
      meta: { // 表示需要登录
        requireAuth: 'true'
      },
      component: () => import('./views/Analysis.vue')
    },
    { // 错题强化
      path: '/wrong',
      name: 'wrong',
      meta: { // 表示需要登录
        requireAuth: 'true'
      },
      component: () => import('./views/Wrong.vue')
    },
    { // 搜索答题界面
      path: '/search',
      name: 'search',
      meta: { // 表示需要登录
        requireAuth: 'true'
      },
      component: () => import('./views/Search.vue')
    },
    { // 巩固练习
      path: '/consolidate',
      name: 'consolidate',
      meta: { // 表示需要登录
        requireAuth: 'true'
      },
      component: () => import('./views/Consolidate.vue')
    },
    { // 考试资讯
      path: '/information',
      name: 'information',
      meta: { // 表示需要登录
        requireAuth: 'true'
      },
      component: () => import('./views/Information.vue')
    },
    {// 路由重定向
      path: '*',
      redirect: '/'
    },
    {
      path: '/404',
      name: 'error-404',
      component: () => import('./views/Error/404.vue')
    }
  ]
})
